package vista;
import java.awt.BorderLayout;
import java.awt.Image;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import javax.swing.WindowConstants;

import bean.EtiquetaImagen;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaNivel extends javax.swing.JFrame {
	private JPanel panNivel;
	private JRadioButton rdbNivel1;
	private JRadioButton rdbNivel2;
	private JRadioButton rdbNivel3;
	private JLabel lblDibujo;
	private JLabel lblEtiqueta;
	private JButton btnPlay;
	
	private EtiquetaImagen etiqueta;

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun." +
					"java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	private static VentanaNivel instancia;

	public final static synchronized VentanaNivel getInstancia() {
		if (instancia == null)
			instancia = new VentanaNivel();
		return instancia;
	}
		
	public VentanaNivel() {
		super();
		etiqueta = new EtiquetaImagen();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				panNivel = new JPanel();
				getContentPane().add(panNivel, BorderLayout.CENTER);
				panNivel.setLayout(null);
				ButtonGroup btgNivel = new ButtonGroup();
				{
					rdbNivel1 = new JRadioButton();
					panNivel.add(rdbNivel1);
					rdbNivel1.setText("Basico");
					rdbNivel1.setBounds(35, 93, 115, 21);
					btgNivel.add(rdbNivel1);
				}
				{
					rdbNivel2 = new JRadioButton();
					panNivel.add(rdbNivel2);
					rdbNivel2.setText("Intermedio");
					rdbNivel2.setBounds(35, 142, 115, 21);
					btgNivel.add(rdbNivel2);
				}
				{
					rdbNivel3 = new JRadioButton();
					panNivel.add(rdbNivel3);
					rdbNivel3.setText("Avanzado");
					rdbNivel3.setBounds(35, 192, 115, 21);
					btgNivel.add(rdbNivel3);
				}
				{
					ImageIcon homero = etiqueta.crearImageIcon("iconos/homero4.JPG");
					//Image imagen = homero.getImage();
			        //ImageIcon aescala = new ImageIcon(
			        //imagen.getScaledInstance(200,200,Image.SCALE_SMOOTH));
					lblDibujo = new JLabel(homero);
					panNivel.add(lblDibujo);
					lblDibujo.setBounds(311, 52, 172, 175);
					//lblDibujo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("iconos/celebracion.gif")));
				}
				{
					btnPlay = new JButton();
					panNivel.add(btnPlay);
					btnPlay.setText("PLAY");
					btnPlay.setBounds(171, 136, 92, 33);
				}
				{
					lblEtiqueta = new JLabel();
					panNivel.add(lblEtiqueta);
					lblEtiqueta.setText("Selecciona un Nivel");
					lblEtiqueta.setBounds(35, 36, 136, 23);
				}
			}
			pack();
			this.setSize(516, 315);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	public void addListener(ActionListener actionListener){
		this.btnPlay.addActionListener(actionListener);
	}
	
	public boolean estaSeleccionadoNivel1(){
		return this.rdbNivel1.isSelected();
	}
	
	public boolean estaSeleccionadoNivel2(){
		return this.rdbNivel2.isSelected();
	}
	
	public boolean estaSeleccionadoNivel3(){
		return this.rdbNivel3.isSelected();
	}
	
	public String getNivel1(){
		return this.rdbNivel1.getText().toLowerCase();
	}
	
	public String getNivel2(){
		return this.rdbNivel2.getText().toLowerCase();
	}
	
	public String getNivel3(){
		return this.rdbNivel3.getText().toLowerCase();
	}
	
	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}

}
